/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import { EntityRepository, Repository } from "typeorm";
import { BlackEntity } from "../entity/BlackEntity";

@EntityRepository(BlackEntity)
export class BlackRepository extends Repository<BlackEntity> {
	
	queryByBingo(bingoId : string) {
		return this.createQueryBuilder("black")
				.innerJoinAndSelect("black.prize", "prize")
				.innerJoinAndSelect("black.member", "member")
				.where("black.prize.bid = :_bingoId", {_bingoId: bingoId})
		    .getMany();
	}

    queryByBingoPrize(bingoId : string, prizeId: number) {
        return this.createQueryBuilder("black")
            .innerJoinAndSelect("black.prize", "prize")
            .innerJoinAndSelect("black.member", "member")
            .where("black.prize.bid = :_bingoId AND black.prize.pid = :_prizeId",
				{_bingoId: bingoId, _prizeId : prizeId})
            .getMany();
    }


}